package com.cssy.authority.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cssy.authority.dao.SysMenuDAO;
import com.cssy.authority.entity.SysMenuDO;
import com.cssy.authority.service.IMenuService;
import com.plat.exception.SyBaseException;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;

@Service("menuService")
public class MenuServiceImpl implements IMenuService{

	@Resource(name = "sysMenuDAO")
	private SysMenuDAO sysMenuDAO;
	
	@Override
	public SearchResult findListByExample(SearchConditions scs)
			throws SyBaseException {
		SearchResult rs=new SearchResult(scs);
		List<SysMenuDO>  list= sysMenuDAO.find(scs);
		rs.setRecordCount(sysMenuDAO.count(scs));
		rs.setResults(list);
		return rs;
	}

	@Override
	public void delete(String id) throws SyBaseException {
		 sysMenuDAO.deleteSysMenuDOByPrimaryKey(Integer.parseInt(id));
	}

	@Override
	public void save(SysMenuDO t) throws SyBaseException {
		if(!"".equals(t.getId())&&t.getId()!=null){
			sysMenuDAO.updateSysMenuDO(t);
		}else{
			sysMenuDAO.insertSysMenuDO(t);
		}
	}

	@Override
	public SysMenuDO findListById(String id) throws SyBaseException {
		return sysMenuDAO.findSysMenuDOByPrimaryKey(Integer.parseInt(id));
	}

}
